package homework.billing;

import homework.billing.meter.*;
import homework.billing.meter.simple.SimpleTaxiMeter;

public class MeterFactory {

    public static FullMeter createMeter(String name)
            throws UnsupportedMeterException {

        if(name.equals("ofo")) {
            return new OfoMeter();
        } else if(name.equals("滴滴")) {
            return new DidiMeter(1.5f, 0.25f);
        } else if(name.equals("simpleTaxi")) {
            return new SimpleTaxiMeter(6, 2, 1.7f);
        } else if(name.equals("锡林浩特") || name.equals("锡林浩特夜")) {

            float startingPrice = 6;
            if(name.equals("锡林浩特夜"))
                startingPrice = 9;

            LadderTaxiMeter ladderMeter = new LadderTaxiMeter(startingPrice, 2.5f);
            ladderMeter.addLadder(2.5f, 1.5f);
            ladderMeter.addLadder(4.5f, 2);
            ladderMeter.addLadder(10.5f, 3);
            return ladderMeter;
        }

        throw new UnsupportedMeterException("没有此计费器名: "+name);
    }
}
